package week3.day19;

/**
 * @Author fengzihao
 * @Date 2024-05-03 19:46
 */
public class TestExceptions {
    public static void main(String[] args) {
        System.out.println("Main start");
        try {
            test1();
        }catch (RunTimeException e){
            e.printStackTrace();
        }
        try {
            test2();
        } catch (MyExceptions e) {
            e.printStackTrace();
        }
        System.out.println("Main end");

    }
    public static void test1(){
        System.out.println("test1 start");
        throw new RunTimeException("运行时异常！");
    }
    public static void test2() throws MyExceptions {
        System.out.println("test2 start");
        throw new MyExceptions("编译时异常");

    }

}
class RunTimeException extends RuntimeException{
    public RunTimeException() {
    }

    public RunTimeException(String message) {
        super(message);
    }
}
class MyExceptions extends Exception{
    public MyExceptions() {
    }

    public MyExceptions(String message) {
        super(message);
    }
}
